package keeto.com.vn.bms.network.task;

import java.io.IOException;

import org.apache.http.client.ClientProtocolException;
import org.json.JSONException;

import keeto.com.vn.bms.config.IBMSCore;
import keeto.com.vn.bms.network.IBMSProtocol;
import keeto.com.vn.bms.network.request.GetListMedicalRecordHospitalRequest;
import keeto.com.vn.bms.network.response.GetListMedicalRecordHospitalResponse;
import keeto.com.vn.bms.utils.BMSListener;

public class TaskGetListMedicalRecordHospital extends AbstractTask {
	String authenKey;
	String Date;
	String Company_id;
	String Hospital_id;

	public TaskGetListMedicalRecordHospital(BMSListener listener,
			IBMSCore core,String Date, String Company_id, String Hospital_id,
			String authenKey) {
		super(listener, core);
		// TODO Auto-generated constructor stub
		this.authenKey = authenKey;
		this.Company_id = Company_id;
		this.Hospital_id = Hospital_id;
		this.Date=Date;
	}

	@Override
	public void run() throws ClientProtocolException, JSONException,
			IOException {
		// TODO Auto-generated method stub
		GetListMedicalRecordHospitalRequest request= new GetListMedicalRecordHospitalRequest();
		request.setAuthenKey(authenKey);
		request.setCompany_id(Company_id);
		request.setHospital_id(Hospital_id);
		request.setDate(Date);
		GetListMedicalRecordHospitalResponse response= protocol.getListRecordHos(request);
		for(BMSListener mListener:listener){
			mListener.finishGetListRecordMedicalHos(response.getReturnCode(), response.getResultMsg(), response.getRecords());
			
		}
		

	}

	@Override
	public void timeoutCallback() {
		// TODO Auto-generated method stub
		for(BMSListener mListener:listener){
			mListener.finishGetListMedicalRecord(IBMSProtocol.STATUS_CODE_GENERIC_FAIL_CONECTTION, "Failed", null);
			
		}
	}

}
